import JsonData from "../../Json.js";
let {brideName, groomName,sharePhoto} = JsonData.invite;
Page({
  data: {
    nickName: "",
    imgUrl: "",
    wechat: "",
    receivedTimeArr: "",
    groomName: groomName
  },
  onShareAppMessage: function(e) {
    return "button" === e.from && console.log(e.target), {
      title: `${brideName}&${groomName}的结婚邀请函`,
      path: "pages/index/index",
      imageUrl: sharePhoto,
      success: function(res) {
        console.log("转发成功:" + JSON.stringify(res));
      },
      fail: function(err) {
        console.log("转发失败:" + JSON.stringify(err));
      }
    };
  },
  onLoad: function(options) {
    if (options.receivedTimeArr) {
      this.setData({
        receivedTimeArr: options.receivedTimeArr
      });
    }
    this.setData({
      nickName: options.nickName,
      imgUrl: "../../images/" + options.imgUrl + ".jpg",
      wechat: options.wechat
    });
  },
  toSessionPage: function() {
    if (this.data.groomName == this.data.nickName) {
      let time = this.data.receivedTimeArr.split(",");
      wx.navigateTo({
        url: "../session/session?receivedTime=" + time[0]
      });
    }
  }
});